<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('拆箱单-修改')" />
	<th:block th:include="include :: businessCSS" />
	<style>
		.main-content{position: relative;}
		.topbtns{position:fixed;top: 0;width: 100%;z-index: 9999;background-color: #fff;}
		.preservationBtn{padding: 10px;margin: 0;position: fixed;top: 0;z-index: 9999;background: #fff;width: 100%;}
		.preservationBtn input{font-size: 16px;background-color: rgb(80, 138, 238);color: #fff;border: none;padding: 5px 30px;border-radius: 5px;cursor: pointer;}
		.layui-table-tool-temp{padding-right: 30px;}
		.getDetailUpload,.getDetailUpload2{cursor: pointer;}
		.layui-table-tool-self{display: none;}
		.tablebody{background-color: #fff;padding: 20px;margin-right: 15px;}
		.tablebody input{display: inline;width: 80%;border: none;}
		.tablebody table{width: 100%;}
		.tablebody th,.tablebody td{border:solid 1px #ddd;padding:10px;font-size:14px;text-align: center;}
	</style>
</head>
<body class="no-skin">
<div class="main-container" id="main-container">
	<div class="main-content">
	<form class="layui-form head-form">
		<div class="north">
			<th:block th:include="include :: business_tpl('top')" />
		</div>
		<div>
			<table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
			<script type="text/html" id="zjtoolbar">
				<div style="padding: 16px;display: flex;justify-content: space-between;">
					<div  style="font-weight: 700;font-size: 18px;">海外头程装箱清单</div>
				</div>
			</script>
		</div>
    </form>
	</div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: businessTableBtn" />
<th:block th:include="include :: inlineJS" />
<script th:src="@{/dhecp/js/queryCondition.js}"></script>

<script th:inline="javascript">
	var datalist=[[${List}]]
	var creationMethod=[[${creationMethod}]]
</script>

<script type="text/javascript">
	var $,layer,form,table,laydate,element;//定义layui模块
	layui.use(['laydate', 'table','form','layer','jquery','util','element'], function () {
		$ = layui.$,layer = layui.layer,form = layui.form,table = layui.table,laydate = layui.laydate,util = layui.util,element=layui.element;
		if (creationMethod == '手动'){
			cols = tablecolsFh();
		} else {
			cols = tablecolsZD();
			//根据coleSize编辑出多少个箱子
			for (let i = 0; i < Number($('#numBox').val()); i++) {
				let  tableData = {
					"align": "center",
					"field": "numRealityDeliver"+(i+1),
					"title": "箱子"+(i+1),
					"width": 95,
				}
				cols[0].push(tableData);
			}

			//将箱子数据赋值
			if (Number($('#numBox').val()) != 0){
				for (let i = 0; i < datalist.length; i++) {
					let ss = datalist[i].boxList.slice(1,datalist[i].boxList.length-1)
					let aa =  ss.split(",");
					for (let j = 0; j < aa.length; j++) {
						let numRe = 'numRealityDeliver'+(j+1)
						datalist[i][numRe] = aa[j]==0?"":aa[j]
					}
				}
			}
		}
		// 初始化表格
		$.tablelist.init({
			elem: '#dhtable'
			,data: datalist
			, page: false
			, even: true
			, limit: 10000
			, totalRow: false
			, cols: cols
			, toolbar: '#zjtoolbar'
			, defaultToolbar: [{title: '列设置', layEvent: 'fieldSet', icon: 'layui-icon-set'}]
			, height: '550'
			, done: function (res, curr, count) {
				datalist = table.cache.dhtable;//每次重载都赋值更新表缓存
				var that = this.elem.next();
				res.data.forEach(function (item, index) {
					if (item.scrapData == "1" && item.serial != "合计") {
						var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", '#e5f3fe');
					} else {
						var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", 'white');
					}
				})
			},success:function(a,b,c){
				console.log(a,b,c)
			}
		});
	});
</script>


</body>
</html>